package com.etc.dao.impl;
import java.sql.ResultSet;
import com.etc.dao.AlbumDao;
import com.etc.entity.Album;
import com.etc.util.DBUtil;

public class AlbumDaoImpl implements AlbumDao{

	@Override
	public Album findAlbumIdByName(String albumName) {
		Album album = null;
		ResultSet rs = DBUtil.query("SELECT album_id FROM album WHERE album_name= ? ", albumName);
		try {
			while (rs.next()) {
				Integer albumId = rs.getInt("album_id");
				album = new Album();
				album.setAlbumId(albumId);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return album;
	}

	@Override
	public int addAlbum(Album album) {
		return DBUtil.update("INSERT INTO album(album_id,album_name,singger_id,album_img_path) VALUES(?,?,?,?)", 
				album.getAlbumId(),album.getAlbumName(),album.getSinggerId(),album.getAlbumImgPath());
	}

	
}
